﻿#ifndef SWITCHWIDGET_H
#define SWITCHWIDGET_H

#include <QWidget>

namespace Ui {
class SwitchWidget;
}

class ChatRoom;
class DispatchWidget;
class QStackedLayout;
class QToolButton;

class SwitchWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SwitchWidget(QWidget *parent = nullptr);
    ~SwitchWidget();

    QWidget *getDynamicWidget() const;
    bool closeDynamic();

    ChatRoom *getChatRoom() const;
    bool isChatRoomOpen(qint64 uniqueId) const;
    void addChatRoom(ChatRoom* newRoom);

    bool isDispatchOpen() const;
    void addDispatch(DispatchWidget *newDispatch);

    void createWeb();
    void showWeb(QToolButton* button, const QUrl &url);
    bool isWeb() const;
    QToolButton *currentButton() const;

    bool isBlank() const;
    QString currentTitle();
    bool closeCurrent();
signals:
    void currentChanged(int index);
private:
    Ui::SwitchWidget *ui;
    QStackedLayout *stackedLayout;
    QToolButton *webButton;
};

#endif // SWITCHWIDGET_H
